class Solution
{
public:
    int minimumRounds(vector<int> &tasks)
    {
        unordered_map<int, int> m;
        for (int t : tasks)
        {
            ++m[t];
        }
        int result = 0;
        for (auto [t, c] : m)
        {
            if (c == 1)
            {
                return -1;
            }
            else if (c % 3 == 0)
            {
                result += c / 3;
            }
            else
            {
                result += c / 3 + 1;
            }
        }
        return result;
    }
};